
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>OpenAPI 文档结构 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="openapi/openapi.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter active" data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    OpenAPI 文档结构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.1" data-path="openapi/openapi.html">
            
                <a href="openapi/openapi.html">
            
                    
                    openapi
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.2" data-path="openapi/info.html">
            
                <a href="openapi/info.html">
            
                    
                    info
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3" data-path="openapi/paths.html">
            
                <a href="openapi/paths.html">
            
                    
                    paths
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1" data-path="openapi/url.html">
            
                <a href="openapi/url.html">
            
                    
                    /add, /del, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1" data-path="openapi/method.html">
            
                <a href="openapi/method.html">
            
                    
                    get, post, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.1" data-path="openapi/parameters.html">
            
                <a href="openapi/parameters.html">
            
                    
                    parameters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.1.1.2" data-path="openapi/requestBody.html">
            
                <a href="openapi/requestBody.html">
            
                    
                    requestBody
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.1.3.1.1.3" data-path="openapi/responses.html">
            
                <a href="openapi/responses.html">
            
                    
                    responses
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1" data-path="openapi/response_code.html">
            
                <a href="openapi/response_code.html">
            
                    
                    200, 400, ...
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1" data-path="openapi/content.html">
            
                <a href="openapi/content.html">
            
                    
                    content
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1.1" data-path="openapi/media.html">
            
                <a href="openapi/media.html">
            
                    
                    text/plain
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1.3.1.1.3.1.1.1.1" data-path="openapi/schema.html">
            
                <a href="openapi/schema.html">
            
                    
                    schema
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.1.4" data-path="openapi/components.html">
            
                <a href="openapi/components.html">
            
                    
                    components
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="schema/">
            
                <a href="schema/">
            
                    
                    常见的 schema 规则
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="schema/string.html">
            
                <a href="schema/string.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="schema/number.html">
            
                <a href="schema/number.html">
            
                    
                    数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="schema/json.html">
            
                <a href="schema/json.html">
            
                    
                    json object
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="schema/array.html">
            
                <a href="schema/array.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="schema/boolean.html">
            
                <a href="schema/boolean.html">
            
                    
                    布尔值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="schema/combining.html">
            
                <a href="schema/combining.html">
            
                    
                    组合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="schema/ref.html">
            
                <a href="schema/ref.html">
            
                    
                    引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="schema/generic.html">
            
                <a href="schema/generic.html">
            
                    
                    通用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >OpenAPI 文档结构</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="openapi">OpenAPI</h1>
<p><a href="https://swagger.io/specification/" target="_blank">OpenAPI</a> &#x662F;&#x4E00;&#x79CD;&#x4E0E;&#x8BED;&#x8A00;&#x65E0;&#x5173;&#x7684;&#x6587;&#x6863;&#xFF0C;&#x7528;&#x6765;&#x63CF;&#x8FF0; web &#x670D;&#x52A1;&#x3002;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">openapi:</span> <span class="hljs-number">3.0</span><span class="hljs-number">.3</span>
<span class="hljs-attr">info:</span>
<span class="hljs-attr">  title:</span> hi
<span class="hljs-attr">  version:</span> <span class="hljs-number">0.0</span><span class="hljs-number">.1</span>

<span class="hljs-attr">paths:</span>
  /hi:
<span class="hljs-attr">    get:</span>
<span class="hljs-attr">      responses:</span>
        <span class="hljs-string">&apos;200&apos;</span>:
<span class="hljs-attr">          description:</span> OK
<span class="hljs-attr">          content:</span>
            text/plain:
<span class="hljs-attr">              schema:</span>
<span class="hljs-attr">                type:</span> string
<span class="hljs-attr">                enum:</span> [<span class="hljs-string">&quot;hello&quot;</span>]
</code></pre>
<p>&#x6BD4;&#x5982;&#x4EE5;&#x4E0A;&#x6587;&#x6863;&#x5C31;&#x63CF;&#x8FF0;&#x4E86;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#xFF0C; &#x5F53;&#x4F60;&#x7528; <code>GET</code> &#x65B9;&#x6CD5;&#x8BBF;&#x95EE; <code>/hi</code> &#x63A5;&#x53E3;&#x65F6;</p>
<pre><code>GET /hi
</code></pre><p>&#x5C31;&#x4F1A;&#x5F97;&#x5230;&#x4E00;&#x4E2A; body &#x4E3A; <code>hello</code> &#x7684;&#x54CD;&#x5E94;</p>
<pre><code>HTTP/1.0 200 OK
Content-Type: text/plain

hello
</code></pre><p>&#x672C;&#x6587;&#x6863;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x5982;&#x4F55;&#x5728; OpenAPI &#x4E2D;&#x63CF;&#x8FF0;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;</p>
<h3 id="openapi-&#x7ED3;&#x6784;">OpenAPI &#x7ED3;&#x6784;</h3>
<p>&#x4E0A;&#x9762;&#x7684;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;&#x6709;&#x51E0;&#x4E2A;&#x5B57;&#x6BB5; <code>openapi</code> , <code>info</code>, <code>paths</code> &#x662F; OpenAPI &#x4E2D;&#x5FC5;&#x4E0D;&#x53EF;&#x5C11;&#x7684;&#x5B57;&#x6BB5;&#xFF0C;&#x5F53;&#x7136;&#x8FD8;&#x6709;&#x5176;&#x5B83;&#x7684;&#x5B57;&#x6BB5;</p>
<pre><code class="lang-yaml"><span class="hljs-attr">openapi:</span> <span class="hljs-number">3.0</span><span class="hljs-number">.3</span> <span class="hljs-comment"># OpenAPI&#x7684;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x4E00;&#x4E9B;&#x5DE5;&#x5177;&#x901A;&#x8FC7;&#x6B64;&#x7248;&#x672C;&#x53F7;&#x6765;&#x89E3;&#x91CA;&#x8BE5;&#x6587;&#x6863;&#xFF0C;&#x975E;&#x63A5;&#x53E3;&#x7248;&#x672C;</span>
<span class="hljs-attr">info:</span>
  <span class="hljs-comment"># &#x5FC5;&#x586B; &#x670D;&#x52A1;&#x4FE1;&#x606F;</span>
<span class="hljs-attr">paths:</span>
  <span class="hljs-comment"># &#x5FC5;&#x586B;&#x63A5;&#x53E3;&#x8DEF;&#x5F84;</span>
<span class="hljs-attr">components:</span>
  <span class="hljs-comment"># &#x7EC4;&#x4EF6;&#xFF0C;&#x4FDD;&#x5B58;openapi&#x4E2D;&#x5404;&#x79CD;&#x5404;&#x6837;&#x7684;&#x7247;&#x6BB5;</span>
<span class="hljs-attr">servers:</span> 
  <span class="hljs-comment"># &#x670D;&#x52A1;&#x540E;&#x7AEF;&#x57FA;&#x672C;&#x5730;&#x5740;&#xFF0C;&#x548C;paths&#x4E2D;&#x7684;&#x8DEF;&#x5F84;&#x62FC;&#x63A5;&#x6210;&#x5B8C;&#x6574;&#x7684;url&#x8DEF;&#x5F84;&#xFF0C;&#x662F;&#x4E2A;&#x6570;&#x7EC4;</span>
<span class="hljs-attr">security:</span> 
  <span class="hljs-comment"># &#x6388;&#x6743;&#x673A;&#x5236;&#xFF0C; &#x6BD4;&#x5982;api_key, auth2 &#x7B49;</span>
<span class="hljs-attr">tags:</span> 
  <span class="hljs-comment"># &#x6807;&#x7B7E;&#xFF0C;&#x6807;&#x8BB0;&#x7528;</span>
<span class="hljs-attr">externalDocs:</span>
  <span class="hljs-comment"># &#x5916;&#x90E8;&#x6587;&#x6863;</span>
</code></pre>
<p>&#x63A5;&#x4E0B;&#x6765;&#x7684;&#x7AE0;&#x8282;&#x4E2D;&#x4F1A;&#x5BF9;&#x5927;&#x90E8;&#x5206;&#x5E38;&#x89C1;&#x7684;&#x5B57;&#x6BB5;&#x8FDB;&#x884C;&#x63CF;&#x8FF0;. &#x672C;&#x6587;&#x6863;&#x5DE6;&#x4FA7;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x4E5F;&#x4F1A;&#x6309;&#x7167; OpenAPI &#x5404;&#x4E2A;&#x5B57;&#x6BB5;&#x7684;&#x5C42;&#x7EA7;&#x4E00;&#x6837;&#x6392;&#x5217;,&#x65B9;&#x4FBF;&#x5FEB;&#x901F;&#x67E5;&#x627E;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="openapi/openapi.html" class="navigation navigation-next navigation-unique" aria-label="Next page: openapi">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"OpenAPI 文档结构","level":"1.1","depth":1,"next":{"title":"openapi","level":"1.1.1","depth":2,"path":"openapi/openapi.md","ref":"openapi/openapi.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2020-08-17T06:07:42.072Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-17T10:32:10.207Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

